package com.czxy.dem01;

public class BankCard {

    private double balance;

    public void drawMoney(double money) throws BankException{
        if (balance>money) {
            balance = balance-money;
            System.out.println("取"+money+"还有"+balance);
        }else {
            throw new BankException("大哥 没那么多钱，咱就别装了");
        }
    }

    public double saveMoney(double money) throws BankException {

        if (money>5000) {
            throw new BankException("大哥能不能少点，这一下我算不过来。");
        }else {
            balance = balance+money;
            return balance;
        }
    }

    @Override
    public String toString() {
        return "BankCard{" +
                "balance=" + balance +
                '}';
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public BankCard(double balance) {
        this.balance = balance;
    }

    public BankCard() {
    }
}
